<template>
  <div class="con">
    <div class="contbox6_10" v-if="type == 1">
      <p class="titlelist6_10 titles">
        采购管理
        <span style="color: #999; font-size: 16px">
          &nbsp;&nbsp;
          <span style="font-size: 16px; color: #2f2c29">/</span>
          &nbsp;&nbsp; </span
        >采购单列表
      </p>
      <div class="content">
        <div class="sousuojg6_10">
          <el-form ref="form" :model="form" label-width="85px">
            <div>
              <el-form-item label="政策标识" style="float: left">
                <el-input
                  v-model="form.policyCode"
                  style="width: 200px"
                ></el-input>
              </el-form-item>

              <el-form-item label="终端类型" style="float: left">
                <el-select
                  v-model="form.productNo"
                  clearable
                  placeholder="请选择类型"
                >
                  <el-option
                    :label="item.label"
                    :value="item.productNo"
                    v-for="(item, index) in options11"
                    :key="index"
                  ></el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="机构名称" style="float: left">
                <el-input
                  v-model="form.officeName"
                  style="width: 200px"
                ></el-input>
              </el-form-item>
              <el-form-item label="收货人" style="float: left">
                <el-input
                  v-model="form.linkName"
                  style="width: 200px"
                ></el-input>
              </el-form-item>
              <el-form-item label="手机号" style="float: left">
                <el-input
                  v-model="form.linkPhone"
                  style="width: 200px"
                ></el-input>
              </el-form-item>
            </div>
            <div class="clearfix" >
              <el-form-item label="采购机构" v-if="false" style="float: left">
                <el-input
                  v-model="form.fromOfficeName"
                  style="width: 200px"
                ></el-input>
              </el-form-item>
              <el-form-item label="采购订单号" style="float: left">
                <el-input
                  v-model="form.orderCode"
                  style="width: 200px"
                ></el-input>
              </el-form-item>
              <el-form-item label="审核状态" style="float: left">
                <el-select
                  v-model="form.checkStatus"
                  clearable
                  placeholder="请选择类型"
                >
                  <el-option label="全部" value=""></el-option>
                  <el-option label="一级服务商待审核" value="1"></el-option>

                  <el-option label="一级服务商已通过" value="2"></el-option>
                  <el-option label="一级服务商已驳回" value="3"></el-option>
                  <el-option label="海科待审核" value="4"></el-option>
                  <el-option label="海科已通过" value="5"></el-option>
                  <el-option label="海科已驳回" value="6"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="发货状态" style="float: left">
                <el-select
                  v-model="form.shipStatus"
                  clearable
                  placeholder="请选择类型"
                >
                  <el-option label="全部" value=""></el-option>
                  <el-option label="待发货" value="0"></el-option>
                  <el-option label="已发货" value="1"></el-option>
                  <el-option label="部分发货" value="2"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="订单状态" style="float: left">
                <el-select
                  v-model="form.orderStatus"
                  clearable
                  placeholder="全部"
                >
                  <el-option label="全部" value=""></el-option>
                  <el-option label="已下单" value="0"></el-option>
                  <el-option label="已取消" value="1"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="下单时间" style="float: left">
                <el-date-picker
                  class="time"
                  type="date"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  placeholder="开始日期"
                  v-model="form.startDate"
                ></el-date-picker>
                <div class="times">至</div>
                <el-date-picker
                  class="time"
                  v-model="form.endDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="结束日期"
                ></el-date-picker>
              </el-form-item>
            </div>
          </el-form>
        </div>
        <div>
          <div class="boxer"></div>
          <div class="buttons">
            <el-button
              v-if="isAuth('purchaseSearch')"
              type="primary"
              @click="onSubmit"
              >搜索</el-button
            >
            <el-button
              @click="rest"
              v-if="isAuth('purchaseReset')"
              style="margin-left: 10px !important; margin-right: 40px"
              >重置</el-button
            >
            <el-button
              class="butt"
              type="primary"
              icon="el-icon-plus"
              @click="establish"
              v-if="isAuth('createDirectOrder')"
              style="
                margin-left: 10px;
                width: 108px;
                padding-left: 4px !important;
              "
              >创建采购单</el-button
            >

            <el-button
              class="butt"
              type="primary"
              @click="batch"
              v-if="isAuth('batchAudit')"
              style="margin-left: 10px"
            >
              批量审核
            </el-button>
            <el-button
              @click="payActiveListExport"
              class="butt"
              style="margin-left: 10px"
              type="primary"
            >
              批量导出
            </el-button>
          </div>
        </div>
        <el-table
          ref="multipleTable"
          :data="tableData"
          tooltip-effect="dark"
          :header-cell-style="{ background: '#F9FAFC', color: '#222' }"
          stripe
          border
          :row-style="{ height: '0px' }"
          :cell-style="{ padding: '0px' }"
          :align="center"
         
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" min-width="30"></el-table-column>
          <el-table-column label="采购订单号" min-width="150" show-overflow-tooltip>
            <template slot-scope="scope">{{ scope.row.orderCode }}</template>
          </el-table-column>
          <el-table-column
            prop="policyCode"
            label="政策标识"
            min-width="150"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="productLabel"
            label="终端类型"
            min-width="150"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="unitAmt"
            label="终端价格（元）"
            min-width="120"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="buyNumber"
            label="采购数量（个）"
            min-width="120"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="amount"
            label="采购总价（元）"
            min-width="120"
          ></el-table-column>
          <el-table-column
            prop="officeName"
            label="机构名称"
            min-width="100"
          ></el-table-column>
          <el-table-column
            v-if="false"
            prop="fromOfficeName"
            label="采购机构"
            min-width="100"
          ></el-table-column>
          <el-table-column
            prop="linkName"
            label="收货人"
            show-overflow-tooltip
            min-width="100"
          ></el-table-column>
          <el-table-column
            prop="linkPhone"
            label="手机号"
            min-width="120"
          ></el-table-column>
          <el-table-column
            prop="addr"
            label="收货地址"
            min-width="200"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            prop="orderTime"
            label="下单时间"
            width="170"
          ></el-table-column>
          <el-table-column label="订单状态" width="100">
            <template slot-scope="scope">
              <span v-if="scope.row.orderStatus == 0">已下单</span>
              <span v-if="scope.row.orderStatus == 1">已取消</span>
            </template>
          </el-table-column>
          <el-table-column label="审核状态" width="150">
            <template slot-scope="scope">
              <div v-if="scope.row.orderStatus == 0">
                <span v-if="scope.row.checkStatus == 1">一级服务商待审核</span>
                <span v-if="scope.row.checkStatus == 4">海科待审核</span>
                <span v-if="scope.row.checkStatus == 2">一级服务商已通过</span>
                <span v-if="scope.row.checkStatus == 3">一级服务商已驳回</span>
                <span v-if="scope.row.checkStatus == 5">海科已通过</span>
                <span v-if="scope.row.checkStatus == 6">海科已驳回</span>
              </div>
              <div v-else>——</div>
            </template>
          </el-table-column>
          <el-table-column label="发货状态" width="100">
            <template slot-scope="scope">
              <span v-if="scope.row.shipStatus == 0">待发货</span>
              <span v-if="scope.row.shipStatus == 1">已发货</span>
              <span v-if="scope.row.shipStatus == 2">部分发货</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="remarks"
            label="备注"
            show-overflow-tooltip
            width="100"
          ></el-table-column>
          <el-table-column label="操作" min-width="260" show-overflow-tooltip>
            <template slot-scope="scope">
              <el-button type="text" @click="catDetail(scope.row)"
                >查看</el-button
              >
              <el-button
                type="text"
                @click="examine(scope.row)"
                v-if="
                  scope.row.auditStatus == '0' && scope.row.orderStatus != '1'
                "
                >审核</el-button
              >
              <el-button
                type="text"
                @click="edit(scope.row)"
                v-if="
                  scope.row.editStatus == '0' && scope.row.orderStatus != '1'
                "
                >编辑</el-button
              >
              <el-button
                type="text"
                @click="cancel(scope.row)"
                v-if="
                  scope.row.cancelStatus == '0' && scope.row.orderStatus != '1'
                "
                >取消</el-button
              >
              <el-button
                type="text"
                @click="payMentes1(scope.row)"
                v-if="
                  scope.row.paymentStatus == '0' && scope.row.orderStatus != '1'
                "
                >打款</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <div></div>
        <el-pagination
          style="text-align: right"
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="form.page"
          :page-sizes="[20, 50, 100]"
          :page-size="form.number"
          layout="total, sizes, prev, pager, next, jumper"
          :total="totalPage"
        ></el-pagination>
      </div>
    </div>

    <!-- 审核弹出框 -->
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="600px"
      :before-close="handleClose"
    >
      <div class="wraps">
        <span style="margin-right: 4px">*</span>审核意见:

        <el-input
          type="textarea"
          style="width: 450px; margin-left: 10px"
          placeholder="请输入内容"
          v-model="examineVal"
        >
        </el-input>
      </div>
      <span
        slot="footer"
        class="dialog-footer"
        style="display:flex:justify-content: center"
      >
        <el-button type="primary" @click="handAdopt" class="adopt"
          >通过</el-button
        >
        <el-button
          @click="handReject"
          class="reject"
          style="background: #f56c6c; color: white; border: 0"
          :loading="requestBool1"
          >驳回</el-button
        >
        <el-button @click="handBankList" class="reject">返回</el-button>
      </span>
    </el-dialog>
    <!-- 取消弹框 -->
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible1"
      width="600px"
      :before-close="handleClose1"
    >
      <div class="wraps">
        <span style="color: red">*</span> 取消原因:
        <el-input
          type="textarea"
          :rows="5"
          maxlength="100"
          style="width: 450px; margin-left: 10px"
          placeholder="请输入内容"
          v-model="cancelVeason"
        >
        </el-input>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handCancel" class="reject">取消</el-button>
        <el-button type="primary" @click="handConfirm" class="adopt"
          >确认</el-button
        >
      </span>
    </el-dialog>

    <el-dialog
      title="提示"
      :visible.sync="dialogVisible3"
      width="400px"
      :before-close="handleClose3"
    >
      <div>您暂未开通直采功能，请先联系归属的一级服务商开通直采功能。</div>
      <span slot="footer" class="dialog-footer" style="text-align: center">
        <el-button
          @click="dialogVisible3 = false"
          type="primary"
          style="padding: 10px 20px"
          >知道了</el-button
        >
      </span>
    </el-dialog>

    <el-dialog
      class="fours"
      :visible.sync="dialogVisible4"
      width="480px"
      :before-close="handleClose4"
    >
      <div
        slot="title"
        class="header-title"
        :class="contract == true ? 'header-titleActive' : ''"
      >
        <div class="titleInfoText">
          {{ titleText }}
        </div>
      </div>
      <div v-if="contract == false">
        您未签约终端采购协议，暂不能申请采购，请点击下方“去签约”按钮进行签约。
      </div>
      <!-- 变换为去签约 -->
      <div v-if="contract == true">
        <h3 style="text-align: center">
          为了保障您的合法权益，请进行电子签章。
        </h3>
        <div
          style="
            color: #f56c6c;
            text-align: center;
            margin-bottom: 20px;
            margin-top: 10px;
          "
        >
          * 请填写真实有效的信息
        </div>
        <el-form>
          <el-form-item
            label="公司名称："
            label-width="150px"
            style="width: 400px"
          >
            <el-input
            
              v-model="form1.companyName"
              class="sign"
              style="width: 200px"
            ></el-input>
          </el-form-item>
          <el-form-item
            class="xinyongCode"
            label="统一社会信用代码或注册工商号："
            label-width="150px"
            
            style="width: 400px"
          >
            <el-input
            
              v-model="form1.companyLic"
             
              class="sign"
              @input="value=>{form1.companyLic=value.replace(/[\W]/g,'')}"
              style="width: 200px"
            ></el-input>
          </el-form-item>

          <el-form-item
            label="法人姓名："
            label-width="150px"
            style="width: 400px"
          >
            <el-input
           
              v-model="form1.legalName"
              class="sign"
              style="width: 200px"
            ></el-input>
          </el-form-item>
          <el-form-item
            label="法人身份证号："
            label-width="150px"
            style="width: 400px"
          >
            <el-input
              v-model="form1.legalNbr"
            
              maxlength="18"
              @input="value=>{form1.legalNbr=value.replace(/[\W]/g,'')}"
              class="sign"
              style="width: 200px"
            ></el-input>
          </el-form-item>

          <el-form-item
            label="办理人姓名："
            label-width="150px"
            style="width: 400px"
          >
            <el-input
              v-model="form1.dealName"
              
              class="sign"
              maxlength="11"
              style="width: 200px"
            ></el-input>
          </el-form-item>
          <el-form-item
            label="办理人身份证号："
            label-width="150px"
            style="width: 400px"
          >
            <el-input
              v-model="form1.dealNbr"
             
              class="sign"
              maxlength="18"
              @input="value=>{form1.dealNbr=value.replace(/[\W]/g,'')}"
              style="width: 200px"
            ></el-input>
          </el-form-item>
          <el-form-item
            label="办理人手机号："
            label-width="150px"
            style="width: 400px"
          >
            <el-input
              v-model="form1.mobile"
              class="sign"
              maxlength="11"
              @input="value=>{form1.mobile=value.replace(/^(0+)|[^\d]+/g,'')}"
              style="width: 200px"
            ></el-input>
          </el-form-item>
          <div style="clear: both"></div>
          <div style="padding-left: 150px; color: #fb932b">
            提示：当前手机号必须可以接收短信，<br />
            如不能接收， 请更换。
          </div>
        </el-form>
        <div style="clear: both"></div>
      </div>

      <span slot="footer" class="dialog-footer" style="text-align: center">
        <el-button
        class="bBox"
          @click="changePage"
          v-if="contract == false"
          :loading="gourlBool"
          >去签约</el-button
        >
        <el-button
          class="aBox"
          v-if="contract == true"
          target="_blank"
          @click="goUrl"
          :loading="loadingBool"
          >信息准确，去签章</el-button
        >
      </span>
    </el-dialog>

    <Tree :showType="showType" @func="transmit" />
  </div>
</template>

<script>
import { CodeToText } from "element-china-area-data";

import axios from "axios";
//引入归属机构
import { CompareDate } from "../../assets/js/commion";
import Tree from "../tree/index";
import https from "../../plugins/https"
// 批量导出
import { exportFile } from "../../plugins/expord"
export default {
  name: "route",
  data() {
    return {
      // 控制显示
      loadingBool: false,
      gourlBool:false,
      options11: null,
      // 控制弹出框
      dialogVisible: false,
      // 取消弹框
      dialogVisible1: false,
      // 显示没权限提示
      dialogVisible3: false,
      // sdajkfhd
      dialogVisible4: false,
      // 驳回节流
      requestBool1: false,
      // 通过节流
      requestBool2: false,
      // 控制签约
      contract: false,
      titleText: "提示",
      mechanismAdd: false,
      mechanismDetails: false,
      mechanismBsiness: false,
      readonly: true,
      typebox: 0,
      treeBool: false,
      showType: false,
      type: 1,
      mechanism: "",
      currentPage: 1, //默认显示第一页
      pageSize: 10, //默认每页显示10条
      totalNum: 0, //总页数
      msg: [],
      memberTypsText: "",
      memberType: [
        {
          value: "",
          label: "全部",
        },
        {
          value: "0",
          label: "OEM",
        },
        {
          value: "1",
          label: "普通代理",
        },
      ],
      // 列表ordercode
      orderCode: "",
      // value: '',
      newType: "",
      checkedAll: false,
      // 审核意见
      examineVal: "",
      // 取消原因
      cancelVeason: "",
      // 审核批量
      examineArr: [],
      totalPage: "",
      formInline: {
        idList: [],
      },
      esignFlowCode: "", //判断是否跳转
      form: {
        productNo: "",
        productLabel: "", //终端名称
        officeName: "", //下单机构
        linkName: "", //联系人
        linkPhone: "", //机构电话
        fromOfficeName: "", //采购机构
        orderCode: "", //单据id
        checkStatus: "", //审核状态
        shipStatus: "", //发货状态
        orderStatus: "", //订单状态
        startDate: "", //下单时间
        endDate: "", //下单结束时间
        officeUid: "", //机构uid
        idList: [],
        page: 1,
        number: 20,
      },
      //签约
      form1: {
        companyLic: "", //信用代码
        companyName: "", //公司名称
        legalName: "", //法人姓名
        legalNbr: "", //法人身份证号
        mobile: "", //手机号
        dealName: "", //办理人姓名
        dealNbr: "", //办理人身份证号
      },
      tableData: [],
      multipleSelection: [],
      SelectData: [],
      //   urltype: this.GLOBAL.httpurl,
    };
  },
  created() {
    this.form1.mobile = localStorage.getItem("username");
    if (sessionStorage.getItem("datas")) {
      sessionStorage.removeItem("datas");
    }

    this.getList();
    console.log(this.isAuth);
    // 调用终端
    this.getTypes();
    this.getAppointment();
  },
  mounted() {},

  components: {
    Tree,
  },
  methods: {
    handleClose4() {
      this.dialogVisible4 = false;
      this.form1.companyLic = "";
      this.form1.companyName = "";
      this.form1.legalName = "";
      this.form1.legalNbr = "";
      setTimeout(() => {
        this.contract = false;
        this.titleText = "提示";
      }, 300);
    },
    getAppointment() {
      axios
        .post("api/direct/getEsignInfo", {})
        .then((res) => {
          console.log("获取的签约信息");
          console.log(res);
          if (res.data.code == "0000") {
            this.form1.companyLic = res.data.data.companyLic;
            this.form1.companyName = res.data.data.companyName;
            this.form1.legalName = res.data.data.legalName;
            this.form1.legalNbr = res.data.data.legalNbr;
            this.form1.mobile = res.data.data.mobile;
            this.form1.id = res.data.data.id;
            this.form1.dealName = res.data.data.dealName;
            this.form1.dealNbr = res.data.data.dealNbr;
            this.esignFlowCode = res.data.data.esignFlowCode;
            if (res.data.data.mobile == "") {
              this.form1.mobile = localStorage.getItem("username");
            }
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    goUrl() {
      var regIdNo = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
      if (
        this.form1.companyLic != "" &&
        this.form1.companyName &&
        this.form1.legalName != "" &&
        this.form1.legalNbr != "" &&
        this.form1.mobile != "" &&
        this.form1.dealName != "" &&
        this.form1.dealNbr != ""
      ) {
        if (this.form1.mobile.length == 11) {
          console.log(this.form1);
          if (regIdNo.test(this.form1.legalNbr)) {
            console.log(this.form1);
            // return
            this.loadingBool = true;
            // 获取出来的地址
            var getUrl = window.location.href;
            this.form1.url = getUrl;
            axios
              .post("api/direct/addEsignInfo", this.form1)
              .then((res) => {

                if (res.data.code == "0000") {
                  window.location.href = res.data.data;
                  this.loadingBool = false;
                  this.dialogVisible4 = false;
                  this.form1.companyLic = "";
                  this.form1.companyName = "";
                  this.form1.legalName = "";
                  this.form1.legalNbr = "";
                } else {
                  layer.open({
                    content: res.data.data,
                    skin: "msg",
                    time: 1, //1秒后自动关闭
                  });
                  this.loadingBool = false;
                  this.gourlBool=false
                }
              })
              .catch((err) => {
                this.loadingBool = false;
                console.log(err);
              });
          } else {
            layer.open({
              content: "身份证号填写有误",
              skin: "msg",
              time: 2, //2秒后自动关闭
            });
          }
        } else {
          layer.open({
            content: "手机号有误",
            skin: "msg",
            time: 2, //2秒后自动关闭
          });
        }
      } else {
        layer.open({
          content: "数据全为必填",
          skin: "msg",
          time: 2, //2秒后自动关闭
        });
      }
    },
    // 切换到签章
    changePage() {
      if (this.esignFlowCode != "") {
        this.gourlBool=true
        this.goUrl();
      } else {
        this.getAppointment();
        this.contract = true;
        this.titleText = "确认签章信息";
      }
    },
    // 批量审核
    batch() {
      this.examineVal = "";
      if (this.SelectData.length >= 1) {
        let newArr = [];
        for (let i = 0; i < this.SelectData.length; i++) {
          console.log(this.SelectData[i].id);
          newArr.push(this.SelectData[i].id);
        }
        this.examineArr = newArr;
        this.dialogVisible = true;
      } else {
        layer.open({
          content: "至少选择一个",
          skin: "msg",
          time: 2, //2秒后自动关闭
        });
      }
    },
    // 驳回
    handReject() {
      if (this.examineVal != "") {
        this.dialogVisible = false;
        this.requestBool1 = true;
        this.$refs.multipleTable.clearSelection();
        axios
          .post("/api/direct/updateCheckStatus", {
            idList: this.examineArr,
            fristChkMemo: this.examineVal,
            fristCkhStatus: "2",
          })
          .then((res) => {
            console.log(res);
            if (res.data.code == "0000") {
              layer.open({
                content: res.data.msg,
                skin: "msg",
                time: 2, //1秒后自动关闭
              });
            } else {
              layer.open({
                content: res.data.msg,
                skin: "msg",
                time: 2, //1秒后自动关闭
              });
            }
            this.getList();
            this.requestBool1 = false;
          })
          .catch((err) => {
            this.requestBool1 = false;
            this.getList();
            console.log(err);
          });
      } else {
        layer.open({
          content: "不能为空",
          skin: "msg",
          time: 2, //1秒后自动关闭
        });
      }
    },
    // 关闭
    handBankList() {
      this.dialogVisible = false;
    },
    // 通过
    handAdopt() {
      if (this.examineVal != "") {
        this.SelectData = [];
        this.$refs.multipleTable.clearSelection();
        this.requestBool2 = true;
        this.dialogVisible = false;
        axios
          .post("/api/direct/updateCheckStatus", {
            idList: this.examineArr,
            fristChkMemo: this.examineVal,
            fristCkhStatus: "1",
          })
          .then((res) => {
            console.log(res);
            if (res.data.code == "0000") {
              layer.open({
                content: res.data.msg,
                skin: "msg",
                time: 2, //1秒后自动关闭
              });
            } else {
              layer.open({
                content: res.data.msg,
                skin: "msg",
                time: 2, //1秒后自动关闭
              });
            }
            this.requestBool2 = false;
            this.getList();
          })
          .catch((err) => {
            console.log(err);
            this.getList();
            this.requestBool2 = false;
          });
      } else {
        layer.open({
          content: "输入不能为空",
          skin: "msg",
          time: 2, //1秒后自动关闭
        });
      }
    },
    // 关闭审核弹框
    handleClose() {
      console.log("发生了点击");
      this.examineArr = [];
      this.examineVal = "";
      this.dialogVisible = false;
    },
    // 关闭取消弹框
    handleClose1() {
      this.cancelVeason = "";
      this.dialogVisible1 = false;
    },

    // 终端类型
    getTypes() {
      axios
        .post("/api/direct/getAllProductNoInfo", {})
        .then((res) => {
          console.log("胡哦去东重大雕刻技法卢卡斯");
          console.log(res);
          this.options11 = res.data.data;
        })
        .catch((err) => {
          console.log(err);
        });
    },

    // 取消取消弹框
    handCancel() {
      this.dialogVisible1 = false;
    },
    // 取消确认弹框
    handConfirm() {
      if (this.cancelVeason != "") {
        axios
          .post("/api/direct/updateOrderStatus", {
            orderCode: this.orderCode,
            remarks: this.cancelVeason,
          })
          .then((res) => {
            console.log(res);
            layer.open({
              content: res.data.msg,
              skin: "msg",
              time: 2, //1秒后自动关闭
            });
            this.getList();
            this.dialogVisible1 = false;
          })
          .catch((err) => {
            console.log(err);
          });
      } else {
        layer.open({
          content: "取消原因不能为空",
          skin: "msg",
          time: 2, //1秒后自动关闭
        });
      }
    },
    // 表格后面的按钮
    // 查看
    catDetail(val) {
      console.log(val);
      this.$router.push({
        name: "catDetail",
        query: {
          orderCode: val.orderCode,
        },
      });
    },
    // 审核
    examine(val) {
      console.log(val.id);
      this.examineVal = "";
      this.examineArr = [];
      this.examineArr.push(val.id);
      // 需要出弹框
      this.dialogVisible = true;
    },
    // 编辑
    edit(val) {
      console.log(val);
      this.$router.push({
        name: "createOrder",
        query: {
          disBool: "f",
          orderCode: val.orderCode,
          checkStatus: val.checkStatus,
        },
      });
    },
    // 取消
    cancel(val) {
      this.cancelVeason = "";
      console.log(val);
      this.orderCode = val.orderCode;
      this.dialogVisible1 = true;
    },
    // 打款
    payMentes1(val) {
      console.log(val);
      this.$router.push({
        name: "payMentes1",
        query: {
          orderCode: val.orderCode,
        },
      });
    },

    // 创建采购单跳转页面
    establish() {
      axios
        .post("/api/direct/addDirectOrder", {})
        .then((res) => {
          if (res.data.code == 3367) {
            // alert("没有权限");
            this.dialogVisible3 = true;
          } else if (res.data.code == 3366) {
            this.dialogVisible4 = true;
          } else {
            // return
            this.$router.push({
              name: "createOrder",
              query: {
                disBool: "t",
              },
            });
          }
        })
        .catch((err) => {
          return;
        });
      return;
    },
    // 切换每页几十条
    handleSizeChange(val) {
      console.log(val);
      this.form.number = val;
      this.getList();
    },
    // 切换页数
    handleCurrentChange(val) {
      console.log(val);
      this.form.page = val;
      this.getList();
    },
    //   获取列表数据
    getList() {
      var data = this.form;
      https.orderListl(data)
        .then((res) => {
          if (res.data.code == "0000") {
            this.tableData = res.data.data;
            this.totalPage = res.data.total;
          }
        })
        .catch((err) => {
          console.log("失败");
        });
    },
    //   获取选中的列
    handleSelectionChange(val) {
      this.SelectData = val;
      console.log(this.SelectData);
    },
    onSubmit() {
      //调用接口
      if (this.form.startDate != "" && this.form.endDate != "") {
        if (CompareDate(this.form.startDate, this.form.endDate)) {
          this.form.page = 1;
          this.getList();
        } else {
          layer.open({
            content: "开始时间不能小于结束时间",
            skin: "msg",
            time: 2, //1秒后自动关闭
          });
        }
      } else {
        this.form.page = 1;
        this.getList();
      }
    },
    memberOffice(val) {
      console.log(val);
    },
    // 支付方式
    payment(val) {
      this.$router.push({
        path: "paymentMethod",
        query: {
          officeUid: val.uid,
          agtType: val.agtType,
        },
      });
    },
    // 重置
    rest() {
      this.form = {
        policyCode: "", //政策标识
        productLabel: "", //终端名称
        officeName: "", //下单机构
        linkName: "", //联系人
        linkPhone: "", //机构电话
        fromOfficeName: "", //采购机构
        orderCode: "", //单据id
        checkStatus: "", //审核状态
        shipStatus: "", //发货状态
        orderStatus: "", //订单状态
        startDate: "", //下单时间
        endDate: "", //下单结束时间
        officeUid: "", //机构uid
        idList: [],
        page: 1,
        number: 20,
      };
      this.getList();
    },

    // 批量导出
    payActiveListExport() {
      if (this.SelectData.length > 0) {
        for (let i = 0; i < this.SelectData.length; i++) {
          //  let pl = { snUid: +this.SelectData[i].id };
          this.form.idList.push(this.SelectData[i].id);
        }
      } else {
        this.form.idList = [];
      }
      var _this = this;
      exportFile("/api/direct/directOrderList/excel/export",_this.form,"采购单列表")
    },
  },
};
</script>

<style scoped>
/deep/ .el-container[data-v-4d4a7ce2] {
  background: #f5f7fa !important;
  height: 100% !important;
}
.con {
  position: relative;
}
/* 单独样式 */
.contbox6_10 {
  width: 100%;
  overflow-x: auto;
  box-sizing: border-box;
  float: left;
}
.titlelist6_10 {
  position: absolute;
  padding-left: 20px;
  height: 40px;
  background: #fff;
  width: 100%;
  float: left;
  line-height: 40px;
  font-size: 16px;
  color: #222;
  border-bottom: 1px solid #ebeef5;
  border-top: 1px solid #ebeef5;
}
.content {
  float: left;
  margin-top: 200px;
  margin-bottom: 0px;
  margin: 36px 0px 0px;
  height: calc(100vh - 100px - 26px);
  background: #fff;
}
.buttons {
  width: 100%;
  float: left;
  border: none;
  margin-bottom: 10px;
}
.buttons .el-button {
  float: left;
  padding: 7px;
}
.el-form-item {
  margin-bottom: 10px;
}
.time {
  width: 136px !important;
}
.time > .el-input__inner {
  width: 100% !important;
}
.times {
  display: inline-block;
  text-align: center;
  width: 20px;
}
.el-col-1 {
  width: 3%;
}
.nav {
  width: 100%;
  display: flex;
}
.clearfix:after {
  display: block;
  height: 0;
  clear: both;
  content: ".";
  visibility: hidden;
}
.titles {
  font-size: 16px;
}

.boxer {
  display: inline-block;
  padding-right: 20px;
  float: left;
  margin-left: 20px;
  display: none;
}
.buttons > .el-button {
  width: 100px;
  padding: 7px;
  height: 32px;
}
.subTtile {
  font-size: 18px;
  font-weight: bold;
}
.titlesSub {
  font-size: 18px;
  font-weight: bold;
  width: 80px;
  display: inline-block;
}
.wraps {
  display: flex;
  align-items: top;
}
/deep/ .el-dialog__footer {
  display: flex;
  justify-content: center;
}
.exports {
  color: #409eff;
  border-color: #409eff;
}
.el-button {
  padding: 0;
}
.reject,
.adopt {
  width: 80px;
  height: 40px;
  background: #fff;
}
.adopt {
  background: #409eff;
  color: white;
}
.aBox {
  width: 200px;
  height: 50px;
  line-height: 50px;
  text-align: center;
  background: rgb(64, 158, 255);
  color: white;
  border-radius: 5px;
  cursor: pointer;
}
.bBox{
  width: 80px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  background: rgb(64, 158, 255);
  color: white;
  border-radius: 5px;
  cursor: pointer;
}
.titleInfoText {
  font-size: 18px;
  color: #303133;
}
.sign {
  width: 260px !important;
}
/deep/ .sign .el-input__inner {
  width: 260px !important;
}
/deep/ .fours .el-dialog__header {
  padding: 0;
}
.header-title {
  padding: 20px 20px 10px;
}
.header-titleActive {
  background: #f6f6f6;
}
/deep/ .xinyongCode .el-form-item__label {
  line-height: 20px !important;
  font-size: 12px;
}
/deep/ .yi .el-input__inner {
  width: 280px;
}
/deep/ .cancelTxt .el-input__inner {
  width: 270px !important;
}
</style>
